###
A Button is used to emit some action when it is pressed.

You will mostly create it, put it into the layout and connect to the 'clicked' event like:

var b = new Button('press me');
b.connect('clicked', function(widget, event)
{
    console.log('clicked');
});

events: ['clicked']

###

class tree.ui.Button extends tree.ui.Widget
    
    constructor: (text) ->
        super
        @htmlelem = document.createElement 'button'
        @htmlelem.className = 'tree-button'
        text ?= ''
        @set_text text
        @has_image = false
        @image = null
    
    set_text: (text) ->
        @has_image = false
        @text = text
        @htmlelem.innerHTML = @text
    
    set_image: (image) ->
        @has_image = true
        @image = image
        @htmlelem.innerHTML = @image.show()
